package com.xidian.zhiancloud.service.riskcontrol.risksystem;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.xidian.zhiancloud.dao.riskcontrol.risksystem.TWarSignCategoryStatusMapper;
import com.xidian.zhiancloud.model.riskcontrol.TRiskPointTypeStatusList;
import com.xidian.zhiancloud.model.riskcontrol.TWarSignCategoryStatusList;
import com.xidian.zhiancloud.model.riskcontrol.entity.TSignCategoryStaEntity;
import com.xidian.zhiancloud.model.syset.ImportUser;
import com.xidian.zhiancloud.model.syset.SysUser;
import com.xidian.zhiancloud.qo.BaseReqQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;

/**
 * 风险管控-系统设置-警示标志类别设置
 */
@Service
public class TWarSignCategoryStatusService extends ServiceImpl
        <TWarSignCategoryStatusMapper, TWarSignCategoryStatusList> {

    @Autowired
    TWarSignCategoryStatusMapper tWarSignCategoryStatusMapper;

    public Page<TWarSignCategoryStatusList> getTWarSignCategoryStatusList(
            BaseReqQuery reqdata, Long companyId){
        PageHelper.startPage(reqdata.getPageNum(), reqdata.getPageSize());
        Page<TWarSignCategoryStatusList> pagedata =tWarSignCategoryStatusMapper
                .getTWarSignCategoryStatusList(reqdata.getSearchKey(),companyId);
        return pagedata;
    }

    public int addTWarSignCategoryStatus
            (TWarSignCategoryStatusList tWarSignCategorySta){
        return tWarSignCategoryStatusMapper.addTWarSignCategoryStatus(tWarSignCategorySta);
    }

    public int updateTWarSignCategoryStatus
            (String id,TWarSignCategoryStatusList tWarSignCategorySta){
        return tWarSignCategoryStatusMapper.updateTWarSignCategoryStatus(id,tWarSignCategorySta);
    }

    /**
     * id放入list
     * @param id id(多个已逗号分隔)
     * @return List集合
     */
    public List<String> getList(String id) {
        List<String> list = new ArrayList<String>();
        String[] str = id.split(",");
        for (int i = 0; i < str.length; i++) {
            list.add(str[i]);
        }
        return list;
    }

    public int deleteTWarSignCategoryStatus(String id){
        List<String> list = getList(id);
        return tWarSignCategoryStatusMapper.deleteTWarSignCategoryStatus(list);
    }

    public Page<TWarSignCategoryStatusList> getExportTSignCategoryStaData
            (Long companyId,String id){
        List<String> list=getList(id);
        Page<TWarSignCategoryStatusList> pagedata =tWarSignCategoryStatusMapper
                .getExportTSignCategoryStaData(companyId,list);
        return pagedata;
    }

    public int addTSignCategoryStaEntity
            (Long companyId,Long userId,TSignCategoryStaEntity signCatSta){
        return tWarSignCategoryStatusMapper.addTSignCategoryStaEntity
                (companyId,String.valueOf(userId),signCatSta);
    }

}
